<template>
  <div class="songSheet" v-if="songsheetList">
    <div class="songSheetBox" v-for="item in songsheetList" :key="item.id" @click="goSongSheet(item.id)">
      <div class="imgBox">
        <img :src="item.coverImgUrl" />
      </div>
      <div class="contentBox">
        <p class="name">{{item.name}}</p>
        <p class="text">
          <span>{{item.trackCount}}首</span>
          <span>{{item.creator.nickname}},</span>
          <span>播放{{Math.floor((item.playCount)/10000)}}万次</span>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  props: ["singerName"],
  data() {
    return {
      songsheetList: ""
    };
  },
  watch: {
    singerName: function() {
      this.$http("/search", {
        params: {
          keywords: this.singerName,
          type: 1000
        }
      }).then(res => {
        console.log(res);
        this.songsheetList = res.data.result.playlists;
      });
    }
  },
  computed: {},
  methods: {
    goSongSheet(id){
      console.log(id);
      this.$router.push({
        name:"musiclistdetail",
        query:{
          idx:id
        }
      })
    }
  },
  created() {
    this.$http("/search", {
      params: {
        keywords: this.singerName,
        type: 1000
      }
    }).then(res => {
      console.log(res);
      this.songsheetList = res.data.result.playlists;
    });
  },
  mounted() {}
};
</script>
<style lang="scss" scoped>
@import "~@/assets/css/common.scss";
.songSheet {
  padding: vw(10);
  .songSheetBox {
    width: 100%;
    display: flex;
    align-items: center;
    padding-bottom: vw(10);
    .imgBox {
      width: vw(50);
      height: vw(50);
      overflow: hidden;
      border-radius: vw(6);
      img {
        width: 100%;
      }
    }
    .contentBox {
      padding-left: vw(10);
      .name {
        font-size: vw(16);
      }
      .text {
        padding-top: vw(2);
        font-size: vw(12);
        span {
          color: #777;
          padding-right: vw(10);
        }
      }
    }
  }
}
</style>